import {createStore} from 'vuex'
export default createStore({
	state:{
		count: 0 ,
		statusBarHeight:10,
		titleBarWidth:350,
		titleBarHeight:40,
		menuButtonHeight:32,
		wxBrowser:false,
		loginStatus:false,
		userType:0,
		phone:'',
		token:'',
		name:'',
		userId:'',
		province:'',
		majorId:'',
		majorText:'',
		schoolId:'',
		schoolText:''
	},
	mutations:{
		logout(state){
			state.loginStatus = false;
			state.token = ''
			state.name = ''
			state.userId = ''
			state.userType = 0
			state.province = ''
			state.majorId = ''
			state.majorText = ''
			state.schoolId = ''
			state.schoolText = ''
			uni.clearStorageSync()
		},
		setUserInfo(state,userInfo){
			state.loginStatus = true
			state.phone = userInfo.phone
			state.userType = userInfo.userType
			state.userId = userInfo.userId
			state.token = userInfo.token
		},
		setIdentity(state,identity){
			state.loginStatus = true
			state.province = identity.province
			state.userType = 1
			state.name = identity.name
			state.majorId = identity.major_id
			state.majorText = identity.major_text
			state.schoolId = identity.school_id
			state.schoolText = identity.school_text
		},
		setUserType(state,userType){
			state.userType = userType
		},
		setStatusBarHeight(state,statusBarHeight){
			state.statusBarHeight = statusBarHeight
		},
		setWxHeader(state,wxHeader){
			state.statusBarHeight = wxHeader.statusBarHeight
			state.menuButtonHeight = wxHeader.menuButtonHeight
			state.titleBarWidth = wxHeader.titleBarWidth
			state.titleBarHeight = wxHeader.titleBarHeight
		}
	}
})